package com.hmall.item.config;


import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
@Slf4j//使用这个注解可以使容器扫描到这个类
public class MydateHandler implements MetaObjectHandler {


    @Override
    public void insertFill(MetaObject metaObject) {
        //log.info("start insert fill ....");
        //this.strictInsertFill(metaObject, "createTime", LocalDateTime.class, LocalDateTime.now());

        metaObject.setValue("createTime",new Date());
        metaObject.setValue("updateTime",new Date());

    }

    @Override
    public void updateFill(MetaObject metaObject) {
        //log.info("start update fill ....");
        //this.strictUpdateFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now());
        metaObject.setValue("updateTime",new Date());
    }
}